// schema扩展相关文档请参阅：https://uniapp.dcloud.net.cn/uniCloud/jql-schema-ext.html
const db = uniCloud.database()
module.exports = {
	trigger: {
		afterCreate: function({
			addDataList
		} = {}) {
			let [{
				review_type,
				article_id: _id
			}] = addDataList
			let collName
			if (review_type == 0) { // 资讯
				collName = 'consult'
			} else if (review_type == 1) { // 备考圈
				collName = 'circle'
			}
			db.collection(collName).where({
				_id
			}).update({
				view_count: db.command.inc(1)
			})
		}
	}
}